<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <h:form id="frmTareas">
        <p:dataList id="dtlTareas" value="#{tareaController.listaTareas}" var="tarea" emptyMessage=" " type="definition" >
            <f:facet name="header">
                Listado de tareas
            </f:facet>
            <strong>#{tarea.usuario.nick}</strong> dice: #{tarea.descripcion}
        </p:dataList>

        <div class="divTextAreaPequenio">
            <p:outputLabel for="txtTarea" value="Tarea" />
            <p:inputTextarea id="txtTarea" styleClass="txtAreaPequenio" 
                             value="#{tareaController.tarea.descripcion}" maxlength="250" required="true" />
        </div>

        <br/>

        <p:commandButton id="btnAddTarea" value="Aceptar" actionListener="#{tareaController.registrarTarea}"
                         process="frmTareas" />

        <p:commandButton id="btnVotarTareas" value="Votar" actionListener="#{tareaController.cargarTareasParaVotar}"
                         process="@this" oncomplete="PF('wvVotacionTareas').show();" update=":tabViewPreProduccion:frmVotarTareas"  />

        <p:commandButton widgetVar="btnOcultoTareas" styleClass="btnOculto" process="@this"
                         actionListener="#{tareaController.consultarTareas}" update="frmTareas" />

    </h:form>

    <ui:include src="votacionTareas.xhtml" />

    <p:socket onMessage="handleMessageTareas" channel="#{tareaController.canal}" />

    <script type="text/javascript">
        function handleMessageTareas() {
            alert('handleMessageTareas...');
            btnOcultoTareas.jq.click();
            //            $('.btnOcultoTareas').click();
        }
    </script>

</ui:composition>
